/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Wit
 */
import java.io.*;
import MyPackage.*;
import plc.language.*;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] argv) {
        try {
            //BufferedReader in2 = new BufferedReader(new StringReader("infix 2+3*5"));
            /*parser p = new parser(new Lexer(new StringReader("device 1 = television 50 watt\n"
                    + "device 2 = television2 40 watt\n"
                    + "button 1 = turn on television;\n"
                    + "button 2 = if ( television is on ) then { turn off television; }")));*/
            parser p = new parser(new Lexer(new FileReader(argv[0])));
            //Object result = p.parse().value;
            AllObjs all=(AllObjs)p.parse().value;
            if(!all.error){
              System.out.println("Electric cost : "+all.elec_cost);
              System.out.println("device list size : "+all.device_list.size());
              System.out.println("button list size : "+all.button_list.size());
            }
             else{
              System.out.println("There is an error in grammar");
            }
            /*Node root = (Node)result;
            root.Print();
            System.out.print("Infix   : ");
            root.PrintInfix();
            System.out.print("\nPrefix  : ");
            root.PrintPrefix();
            System.out.print("\nPostfix : ");
            root.PrintPostfix();
            System.out.println("\nResult  : "+root.GetResult());*/
            //Object result = p.parse().value;
            //System.out.println("result : "+result);
        } catch (Exception e) {
            /* do cleanup here -- possibly rethrow e */
            e.printStackTrace();
        }        // TODO code application logic here
    }
}
